<?php

namespace App\Http\Controllers\V1\Api;

use App\Http\Controllers\V1\Api\BaseController;
use App\Models\V1\Game;
use App\Models\V1\ProductsLogs;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class ProductController extends BaseController
{
    /**
     * 产品列表
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function index(Request $request){
        $model=new Game();
        $data=$model->get();
        return ajax_output(200,"成功",$data);
    }

    /**
     * 产品日志
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function logs(Request $request){
        $product_id=$request->input('product_id',0);
        $keyword=$request->input('keyword','');
        if(empty($product_id)){
            return ajax_output(300,"参数错误");
        }
        $query=ProductsLogs::query();
        if($product_id){
            $query->where('product_id',$product_id);
        }
        if(!empty($keyword)){
            $query->where('title','like','%'.$keyword."%");
        }
        $data=$query->orderBy('id','desc')->get();
        return ajax_output(200,"成功",$data);
    }



}
